<template>
  <a-card :bordered="false">
      <!-- 查询区域 -->
    <div class="table-page-search-wrappe">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="团队名称">
              <select-team-input v-model="queryParam.teamId" :teamType="0" :tdlx="3" multi/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="时间(年度)">
              <a-date-picker
                mode="year"
                placeholder="请选择年份"
                format="YYYY"
                v-model="queryParam.year"
                style="width:100%"
                :allowClear="false"
                :open="yearShowOne"
                @openChange="openChangeOne"
                @panelChange="panelChangeOne"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset()" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('资金调拨利息')" :disabled="isDisabledAuth('ErpCapitalAllotInterestReportList:export')">导出</a-button> 
      <a-popover title="自定义列" trigger="click" placement="leftBottom">
        <template slot="content">
          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
            <a-row>
              <template v-for="(item,index) in defColumns">
                <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                  <a-col :span="12"><a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox></a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a style="float: right;"><a-icon type="setting" :style='iconStyle'/></a>
      </a-popover>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :components="drag(columns)"
        bordered
        rowKey="teamId"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">
      </a-table>
    </div>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'
  import moment from 'moment'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
  import {tableDragResize} from '@/utils/draggable-multistage'

  export default {
    name: 'ErpCapitalAllotReportList',
    mixins:[JeecgListMixin, mixinDevice, DisabledAuthFilterMixin,tableDragResize],
    components: {
      SelectTeamInput,
    },
    data () {
      return {
        queryParam:{
          year:moment(new Date()).format('YYYY'),
        },
        yearShowOne:false,
        ipagination: {
          current: 1,
          pageSize: 99999999,
          pageSizeOptions: ['10', '20', '30', '50', '100', '200'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        description: '资金调拨利息',
        //表头
        columns:[],
        //列设置
        settingColumns:[],
        // 列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (text,r,index) {
              return (!text.rowIndex) ? (parseInt(index) + 1) : text.rowIndex;
            }
          },
          {
            title:'团队名称',
            align:"center",
            dataIndex: 'teamId_dictText',
            width:250,
            ellipsis: true,
          },
          {
            title:"团队资金结余（元）",
            align:"center",
            dataIndex: 'data',
            children:[
              {
                title:'1月',
                align:"center",
                dataIndex: 'jan',
                ellipsis: true,
                width:90,
              },
              {
                title:'2月',
                align:"center",
                dataIndex: 'feb',
                width:90,
                ellipsis: true,
              },
              {
                title:'3月',
                align:"center",
                dataIndex: 'mar',
                width:90,
                ellipsis: true,
              },
              {
                title:'4月',
                align:"center",
                dataIndex: 'apr',
                width:90,
                ellipsis: true,
              },
              {
                title:'5月',
                align:"center",
                dataIndex: 'may',
                width:90,
                ellipsis: true,
              },
              {
                title:'6月',
                align:"center",
                dataIndex: 'jun',
                width:90,
                ellipsis: true,
              },
              {
                title:'7月',
                align:"center",
                dataIndex: 'jul',
                width:90,
                ellipsis: true,
              },
              {
                title:'8月',
                align:"center",
                dataIndex: 'aug',
                width:90,
                ellipsis: true,
              },
              {
                title:'9月',
                align:"center",
                dataIndex: 'sept',
                width:90,
                ellipsis: true,
              },
              {
                title:'10月',
                align:"center",
                dataIndex: 'oct',
                width:90,
                ellipsis: true,
              },
              {
                title:'11月',
                align:"center",
                dataIndex: 'nov',
                width:90,
                ellipsis: true,
              },
              {
                title:'12月',
                align:"center",
                dataIndex: 'dec',
                width:90,
                ellipsis: true,
              },
            ]
          },
          {
            title:'本年资金调拨利息（元）',
            align:"center",
            dataIndex: 'sumAmount',
            width:180,
            ellipsis: true,
          },
        ],
        url: {
          list: "/api/erp/finance/report/erpCapitalAllotInterestReport/list", 
          exportXlsUrl: "/api/erp/finance/report/erpCapitalAllotInterestReport/exportXls",
        },
        //代码生成后需手动设置流程编码
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      searchQuery() {
        this.onClearSelected();
        this.loadData(1)
      },
      searchReset() {
        this.queryParam = {}
        this.$set(this.queryParam,"year",moment(new Date()).format('YYYY'));
        this.onClearSelected();
        this.loadData(1)
      },
      // 弹出日历和关闭日历的回调
      openChangeOne(status){
          //status是打开或关闭的状态
          this.yearShowOne =  !this.yearShowOne
      },
      // 得到年份选择器的值
      panelChangeOne(value){
        console.log(moment(value).format('YYYY'));
          this.queryParam.year = moment(value).format('YYYY')
          this.yearShowOne =  !this.yearShowOne
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
